
import axios from '../utils/axios';

export const loginRequest = async (loginData) => {
    let response = {}
    await axios.post('/auth/login', loginData)
    .then((res) => {
        response = res
    })
    .catch((error)=>{
        response = error.response
    })

    return response
}
export const loginCode = async() => {
    let response = {}
    await axios.get('/auth/code')
    .then((res) => {
        response = res
    })
    .catch((error)=>{
        response = error.response
    })
    return response
}

export const registerNew = async() => {
    let response = {}
    await axios.get('/auth/code')
    .then((res) => {
        response = res
    })
    .catch((error)=>{
        response = error.response
    })
    return response
}


export const getUserInfo = async() => {
    let response = {}
    const token = localStorage.getItem('token')
    await axios.get('/auth/info', {
        headers: {
            Authorization: token
        }
    })
    .then((res) => {
        response = res
    })
    .catch((error)=>{
        response = error.response
    })
    return response
}

export const logOut = async() => {
    let response = {}
    const token = localStorage.getItem('token')
    await axios.delete('/auth/logout',{
        headers: {
            Authorization: token
        }
    })
    .then((res) => {
        response = res
    })
    .catch((error)=>{
        response = error.response
    })
    return response
}

